From: Daniel van Vugt Date: Tue, 25 May 2021 09:33:01 +0000 (+0800) Subject: st/theme-node-drawing: Conditionally paint the center shadow rectangle X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~461^2^2~119 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=9b3ee774f622c6ac1d4857d6ae6dbe78d475dfe0;p=gnome-shell.git st/theme-node-drawing: Conditionally paint the center shadow rectangle Only when part of it is actually visible. Because the central rectangle is generally the largest part, this eliminates most of the shadow's render time. For example, animating `.workspace-background` by tapping Super, the shell's overall render time is reduced about 15%. Part-of: --- diff --git a/src/st/st-theme-node-drawing.c b/src/st/st-theme-node-drawing.c index b32c76be2..72745ed66 100644 --- a/src/st/st-theme-node-drawing.c +++ b/src/st/st-theme-node-drawing.c @@ -2021,6 +2021,8 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state, gfloat shadow_blur_radius, x_spread_factor, y_spread_factor; float rectangles[8 * 9]; gint idx; + ClutterColor background_color; + static const ClutterColor invisible_occluded = {3, 2, 1, 0}; if (paint_opacity == 0) return; @@ -2178,16 +2180,23 @@ st_theme_node_paint_sliced_shadow (StThemeNodePaintState *state, rectangles[idx++] = s_bottom; } - /* Center middle */ - rectangles[idx++] = left; - rectangles[idx++] = top; - rectangles[idx++] = right; - rectangles[idx++] = bottom; + /* Center middle is not definitely occluded? */ + st_theme_node_get_background_color (node, &background_color); + if (!clutter_color_equal (&background_color, &invisible_occluded) || + paint_opacity < 255 || + xoffset > shadow_blur_radius || left < 0 || + yoffset > shadow_blur_radius || top < 0) + { + rectangles[idx++] = left; + rectangles[idx++] = top; + rectangles[idx++] = right; + rectangles[idx++] = bottom; - rectangles[idx++] = s_left; - rectangles[idx++] = s_top; - rectangles[idx++] = s_right; - rectangles[idx++] = s_bottom; + rectangles[idx++] = s_left; + rectangles[idx++] = s_top; + rectangles[idx++] = s_right; + rectangles[idx++] = s_bottom; + } if (xend > right) {